package model

import (
	"appengine"
	"appengine/datastore"
	"appengine/memcache"
	"entity"
)

var Domain_CacheName string = "_domain_"

func CheckExist(domainName string) (exist bool) {
	exist = false
	return
}

func AddDomain(c appengine.Context, obj entity.Domain) error {
	cacheTitle := Domain_CacheName + obj.Domain
	key := datastore.NewKey(c, "Domain", obj.Domain, 0, nil)
	_, err := datastore.Put(c, key, &obj)
	if err != nil {
		return err
	}
	itemCache := &memcache.Item{
		Key:    cacheTitle,
		Object: obj,
	}
	memcache.Gob.Set(c, itemCache)
	return nil
}
